﻿using Microsoft.Win32;
using MS.Win32;
using System;

namespace ThinkPadDockHelper
{
    internal static class RegistryUtil
    {
        private static readonly string TPDHKeyName = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" + Properties.Resources.ServiceName;
        private static readonly string UndockedLidCloseActionAC = "undockedLidCloseActionAC";
        private static readonly string UndockedLidCloseActionDC = "undockedLidCloseActionDC";

        public static uint GetUndockedLidCloseActionACValueIndex()
        {
            var value = (uint)(int)Registry.GetValue(TPDHKeyName, UndockedLidCloseActionAC, NativeMethods.POWERBUTTON_ACTION_INDEX_SLEEP);

            return value;
        }

        public static void SetUndockedLidCloseActionACValueIndex(uint value)
        {
            Registry.SetValue(TPDHKeyName, UndockedLidCloseActionAC, value, RegistryValueKind.DWord);
        }

        public static uint GetUndockedLidCloseActionDCValueIndex()
        {
            var value = (uint)(int)Registry.GetValue(TPDHKeyName, UndockedLidCloseActionDC, NativeMethods.POWERBUTTON_ACTION_INDEX_SLEEP);

            return value;
        }

        public static void SetUndockedLidCloseActionDCValueIndex(uint value)
        {
            Registry.SetValue(TPDHKeyName, UndockedLidCloseActionDC, value, RegistryValueKind.DWord);
        }
    }
}
